package com.example.demo2;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;

public class MainActivity extends Activity {
	private AutoCompleteTextView acTextView;
	private String[] res = {"beijing1","beijing2","beijing3","shanghai1","shanghai2"};
	
	private MultiAutoCompleteTextView macTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*
         * 1 初始化控件
         * 2 需要一个适配器 适配 acTextview
         * 3 初始化数据源-----去匹配文本框中文本输入的内容
         * 4 将adapter与控件 auto
         */
        acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
        		android.R.layout.simple_list_item_1,res);
        acTextView.setAdapter(adapter);
        
        macTextView = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
        macTextView.setAdapter(adapter);
        macTextView.setTokenizer( new MultiAutoCompleteTextView.CommaTokenizer());
        /*
         * 设置分隔符
         */
        
    }
    
}
